<template>
	<div>
		<div class="h2">未签到人员列表</div>
		<div class="option">
			<a-button type="primary" class="btn" @click="setSignMore">批量签到</a-button>
		</div>
		<el-table :data="data" v-loading="loading" border :max-height="tableHeight" 
		@selection-change="handleSelectionChange"
		highlight-current-row style="width: 100%;">
			<el-table-column type="selection" width="55" fixed="left"></el-table-column>
			<el-table-column type="index" label="序号" width="60" fixed="left"></el-table-column>
			<el-table-column prop="Name" label="姓名" min-width="100" fixed="left">
				<template slot-scope="scope">
					<i :title="scope.row.Sex==1?'男':'女'" :class="{'iconfont':true, 'icon-xingbienan':scope.row.Sex==1,'icon-xingbienv':scope.row.Sex==2}" :style="{'color': scope.row.Sex==1?'blue':'red'}" @click="deleteList(scope.row)"></i>{{ scope.row.Name }}
				</template>
			</el-table-column>
			<el-table-column prop="UserNo" label="学号" min-width="100"></el-table-column>
			<el-table-column prop="TypeName" label="类型" min-width="140"></el-table-column>
			<!-- <el-table-column prop="AddTime" label="签到时间" min-width="200"></el-table-column> -->
			<el-table-column label="操作" width="140" fixed="right">
				<template slot-scope="scope">
					<a-tag @click="setSign(scope.row)" style="cursor: pointer;" color="red">签到</a-tag>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination
			@size-change="handleSizeChange"
			@current-change="handleCurrentChange"
			:current-page="pagination.currentPage"
			:page-sizes="pagination.pageSizeOptions"
			:page-size="pagination.pageSize"
			layout="total, sizes, prev, pager, next, jumper"
			:total="pagination.total"
		></el-pagination>
	</div>
</template>

<script>
import Func from '@/utils/func';
import { GetActivitySignNoSignUserPageList,DoSignActivityMember } from '@/api/follow';
const data = [];
export default {
	components: {
	},
	data() {
		return {
			data,
			form: this.$form.createForm(this, {
				name: 'advanced_search'
			}),
			pagination: {
				currentPage: 1,
				pageSize: this.global.pageSize,
				pageSizeOptions: this.global.pageSizeOptions, // 每页中显示的数据
				showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
			},
			loading: false,
			values: {},
			tableHeight: parseFloat(window.innerHeight - 160),
			multipleSelection:[]
		};
	},
	computed: {},
	created() {
		this.getList();
	},
	mounted() {},
	methods: {
		setSignMore(){
			if(this.multipleSelection.length==0){
				this.$message.error('请选择要签到的成员！')
				return false
			}
			let that = this
			this.$confirm({
				title: '提示',
				content: `您确定要给选中成员批量签到吗？`,
				okText: '确认',
				cancelText: '取消',
				async onOk() {
					let data = {};
					data.activitySignID = that.$route.query.ID
					let list = that.multipleSelection
					for (let i = 0, len = list.length; i < len; i++) {
						data.activityMemberID = list[i].ID
						let res = await DoSignActivityMember(data);
						if(res.data.code==0){
							that.$message.success(res.data.msg);
						}else{
							that.$message.error(res.data.msg);
						}
					}
					that.$message.success('签到成功！');
					that.getList()
				}
			});
		},
		handleSelectionChange(val) {
		        this.multipleSelection = val;
		      },
					async setSign(text){
						let that = this;
						this.$confirm({
							title: '提示',
							content: `您确定要给该成员签到吗？`,
							okText: '确认',
							cancelText: '取消',
							async onOk() {
								let data = {};
								data.activitySignID = that.$route.query.ID
								data.activityMemberID = text.ID
								let res = await DoSignActivityMember(data);
								if(res.data.code==0){
									that.$message.success(res.data.msg)
									that.getList()
								}else{
									that.$message.error(res.data.msg)
								}
							}
						});
					},
		handleReset() {
			this.form.resetFields();
			this.values = {};
			this.getList();
		},
		handleSizeChange(val) {
			this.pagination.pageSize = val;
			this.getList();
		},
		handleCurrentChange(val) {
			this.pagination.currentPage = val;
			this.getList();
		},
		async getList() {
			this.loading = true;
			let data = {};
			if (this.values) {
				data = this.values;
			}
			data.id = this.$route.query.ID
			data.pageIndex = this.pagination.currentPage;
			data.pageSize = this.pagination.pageSize;
			let res = await GetActivitySignNoSignUserPageList(data);
			this.loading = false;
			this.data = res.data.data;
			const pagination = { ...this.pagination };
			pagination.total = res.data.pageInfo.TotalItemCount;
			this.pagination = pagination;
		},
		closeFun(data) {}
	}
};
</script>

<style lang="less" scoped>
/deep/.ant-form-item {
	display: flex;
	margin-bottom: 10px !important;

	/deep/.ant-form-item-label {
		width: 80px;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		text-align: right;
	}
	/deep/.ant-form-item-control-wrapper {
		flex: 1;
	}
}
/deep/.el-table th.is-leaf {
	background: #fafafa;
}
/deep/.el-table td,
/deep/.el-table th {
	padding: 5px;
}
.option {
	margin-top: 10px;
	margin-bottom: 20px;
	overflow: hidden;
}
.option .btn {
	height: 36px;
	line-height: 36px;
	padding: 0 10px;
	float: left;
	background: #1890ff;
	color: #fff;
	margin-right: 10px;
	border-radius: 3px;
	cursor: pointer;
	border: none;
}
.foot {
	text-align: center;
	margin-top: 100px;
}
.el-pagination {
	margin-top: 10px;
}
</style>
